package com.example.environment.entity.base;


import com.example.environment.enums.HttpMsgEnum;

/**
 *  @author: wangbo(1141294273@qq.com)
 *  @Date: 2021/1/29 16:41
 *  @Description: 公共返回对象
 */
public class BaseResponseBean<T> {

    /*
     * 描述
     */
    private String msg;

    /*
     * 错误码
     */
    private String code;

    /*
     * 响应数据
     */
    private T data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    /**
    * @Description 成功返回
    * @Author  wangbo
    * @Date   2021/1/29 17:06
    * @Param
    * @Return
    * @Exception
    *
    */
    public  BaseResponseBean isSuccess(Object data){
        BaseResponseBean baseResponseBean = new BaseResponseBean();
        baseResponseBean.setMsg(HttpMsgEnum.SUCCESS.getName());
        baseResponseBean.setCode(HttpMsgEnum.SUCCESS.getCode());
        baseResponseBean.setData(data);
        return baseResponseBean;
    }

    /**
     * @Description 成功返回
     * @Author  wangbo
     * @Date   2021/1/29 17:06
     * @Param
     * @Return
     * @Exception
     *
     */
    public  BaseResponseBean isSuccess(){
        BaseResponseBean baseResponseBean = new BaseResponseBean();
        baseResponseBean.setMsg(HttpMsgEnum.SUCCESS.getName());
        baseResponseBean.setCode(HttpMsgEnum.SUCCESS.getCode());
        return baseResponseBean;
    }

    /**
     * @Description 返回失败
     * @Author  wangbo
     * @Date   2021/1/29 17:06
     * @Param
     * @Return
     * @Exception
     *
     */
    public  BaseResponseBean isError(String msg,  Object data){
        BaseResponseBean baseResponseBean = new BaseResponseBean();
        baseResponseBean.setMsg(msg);
        baseResponseBean.setCode(HttpMsgEnum.DISABLE.getCode());
        baseResponseBean.setData(data);
        return baseResponseBean;
    }
    /**
     * @Description 返回失败
     * @Author  wangbo
     * @Date   2021/1/29 17:06
     * @Param
     * @Return
     * @Exception
     *
     */
    public  BaseResponseBean isError(String msg){
        BaseResponseBean baseResponseBean = new BaseResponseBean();
        baseResponseBean.setMsg(msg);
        baseResponseBean.setCode(HttpMsgEnum.DISABLE.getCode());
        return baseResponseBean;
    }
}

